<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>抱抱堂-摇摇乐</title>
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="{:C('IMG_PATH')}static/css/main.css?v=12">
    <style>
    </style>
</head>
<body class="mycard-bg">
<section class="list">
    <ul>
        <li class="brief">
            <div>
                <h5>{$cardDetail.card_name}</h5>
            </div>
            <section><p>卡券号:{$cardDetail.card_num}</p></section>
            <section><p>{$cardDetail.card_intro}</p></section>
            <section class="gift_personal_info">
                <form name="" method="post" class="form_profile">
                    <input type="hidden" name="card_num" value={$cardDetail.card_num} />
                    <input type="hidden" name="card_id" value={$cardDetail.id} />
                    <p><input name="key" type="password" placeholder="核销密码" /></p>
                    <section class="captcha_box">
                        <input name="verify" type="text" placeholder="验证码" />
                        {:sp_verifycode_img('length=4&font_size=20&width=248&height=42&use_noise=1&use_curve=0','style="cursor: pointer;" title="点击获取"')}
                    </section>
                    <section class="gift_btn">
                        <button class="long-yellow-btn gotit-btn">立刻核销</button>
                    </section>
                </form>
            </section>
        </li>
    </ul>
</section>
<footer class="white"><img src="{:C('IMG_PATH')}/static/img/logo_gray.png" /></footer>
</body>
<script src="{:C('IMG_PATH')}static/js/zepto.min.js"></script>
<script>
    (function(){
        $(".form_profile").on('submit', function(e){
            e.preventDefault();
            var formstr = $(".form_profile").serialize();
            $.ajax({
                url : "{:U('Portal/OpenApi/cardVerification')}",
                cache : false,
                type : "POST",
                dataType : "json",
                data : formstr,
                success : function(msg, textStatus){
                    if (msg.errcode == 0) {
                        if (msg.data.status == 0) {
                            alert('核销成功');
                        } else if (msg.data.status == 1){
                            alert('参数异常');
                        } else if (msg.data.status == 2){
                            alert('无效的卡券');
                        } else if (msg.data.status == 3){
                            alert('核销密码错误');
                        } else if (msg.data.status == 4){
                            alert('核销失败');
                        } else if (msg.data.status == 5){
                            alert('验证码错误');
                        }
                        return false;
                    } else {
                        alert('核销失败，请稍后重试');
                        return false;
                    }
                },
                error : function(){
                    alert('核销失败，请稍后重试');
                    return false;
                }
            });
        });
    })();
</script>
</html>